#Include <..\include\Common_For_PageManager.au3>
#Include <GuiButton.au3>
#Include <GuiTab.au3>
#Include <Clipboard.au3>

AutoItSetOption("MustDeclareVars", 1)   ;Variables must be pre-declared.


Dim Const $sCorrectResultPath 			= "C:\Thumbnail View\Correct Resut\"   ;Corretc result file path.
Dim Const $sTestResultPath				= "C:\Thumbnail View\Perform Result\"   ;Proformed result file path.
Dim Const $iNumber 						= Common_GetNumberInExcelSheet($oExcel,$sThumbanilViewFunctionName)  
Dim Const $iCurrentSheetTotalLineNumber = $iNumber[0]   ;Get all number of rows in current excel sheet.
Dim Const $sFunctionFolderPath 			= "C:\Thumbnail View\"  
Dim Const $sSpecialFolderPath 			= "C:\Thumbnail View\Special Sample\"  
Dim Const $sFEFolderPath 				= "C:\Thumbnail View\FE Sample\"  
Dim Const $sSEFolderPath 				= "C:\Thumbnail View\SE Sample\"  
Dim Const $sProtectPDFFile 				= "AutumnView_Passwod123.PDF"  
Dim Const $sOCRSampleFile 				= "OCR.jpg"
Dim Const $sReplaceSampleFile 			= "ReplaceSample.jpg"
Dim Const $sSaveAsFileName_1 			= "SaveAsFileName_1"
Dim Const $sSaveAsFileName_2 			= "SaveAsFileName_2"
Dim Const $sSaveAsFileName_3 			= "SaveAsFileName_3"
Dim Const $sSaveAsFileName_4 			= "SaveAsFileName_4"
Dim Const $sSaveAsFileName_5 			= "SaveAsFileName_5"
Dim Const $sSaveAsFileName_6 			= "SaveAsFileName_6"
Dim Const $sSaveAsFileName_7 			= "SaveAsFileName_7"
Dim Const $sSaveAsFileName_8 			= "SaveAsFileName_8"

Dim Const $sBMP_Format 		= '.bmp'
Dim Const $sTIF_Format 		= '.tif'
Dim Const $sJPG_Format 		= '.jpg'
Dim Const $sPDF_Format 		= '.pdf'
Dim Const $sSpecialFileName = '!@#$%&()'
Local $sFailLogMsg = ''
Local $sCusMsg = ''
;Dim Const $CommonWindowCtrlInfro = '[Class:#32770]'
Dim Const $CommonWindowCtrlInfro = ''

Dim Const $sExcelSheetName = 'Thumbnail view'
Dim Const $iRescolumn = 14

#cs

	If $bIsExecuteFunction Then
		Common_ScreenCaprureWindow($sTestResultPath,$sCaptureImage,$hMenu) 
		Local $bCompareFile = Common_CompareFile($sTestResultPath & $sCaptureImage, $sCorrectResultPath & $sCaptureImage)  			
		If $bCompareFile Then	
			Common_WriteLog($sPass, $TestCaseID,$sThumbanilViewFunctionName,$bReproduceTestCase)   
			Common_Close_PM($hPMHandle) 
			Common_WiteTestCaseExecuteRecode($sTempTXTPath,$TestCaseID)
			Return 1   
		Else
			$sErrorFunction = ""    
		EndIf
	EndIf
	
#ce

;Key Value:
Dim Const $sPMTitleAtPerformResultFolder 				  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'PMTitleAtPerformResultFolder')
Dim Const $sPMTitleAtFunctionFolder						  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'PMTitleAtFunctionFolder')
Dim Const $sViewMenuHotKey 								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'ViewMenuHotKey')
Dim Const $sEditMenuHotKey 								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'EditMenuHotKey')
Dim Const $sThumbnailviewSizeHotKey 					  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'ThumbnailviewSizeHotKey')
Dim Const $sSelectAllHotKey 							  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SelectAllHotKey')
Dim Const $sOCRDialogTitle 								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'OCRDialogTitle')
Dim Const $sToolbarCtrlInfo 							  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'Toolbar'))
Dim Const $sSwitchToViewHotKey 							  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SwitchToViewHotKey')
Dim Const $sFileMenuHotKey 								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'FileMenuHotKey')
Dim Const $sSavaAsDialogTitle_1 						  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SavaAsDialogTitle_1')
Dim Const $sSavaAsDialogTitle_2 						  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SavaAsDialogTitle_2')
Dim Const $sSaveAllFilesAs 								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SaveAllFilesAsTitle' )
Dim Const $sCancelButtonInSaveAsDlgCtrlInfo 			  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'CancelButtonInSaveAsDlg'))
Dim Const $sSaveButtonInSaveAsDlgCtrlInfo 			   	  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SaveButtonInSaveAsDlg')
Dim Const $sFileNameEditBoxInSaveAsDlgCtrlInfo 			  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'FileNameEditBoxInSaveAsDlg'))
Dim Const $sSaveAsTypeCtrlInfo 							  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SaveAsType' ))
Dim Const $sAlertMessage_EmptyFileNameForSaveAsDlgTitle   = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'AlertMessage_EmptyFileNameForSaveAs' )
Dim Const $sAlertMessage_IllegalFileNameForSaveAsDlgTitle = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'AlertMessage_IllegalFileNameForSaveAs')
Dim Const $sAlertMessage_FileNameExistForSaveAsDlgTitle   = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'AlertMessage_FileNameExistForSaveAs' )
Dim Const $sAlertMessage_ConfirmSaveAsDlgTitle 			  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'AlertMessage_ConfirmSaveAs')
Dim Const $sCancelButtonInConfirmSaveAsDlg 				  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'CancelButtonInConfirmSaveAsDlg')
Dim Const $sYesButtonInConfirmSaveAsDlg 				  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'YesButtonInConfirmSaveAsDlg')

Dim Const $sSaveAnnotationSettingDlgTitle 				  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SaveAnnotationSettingDlgTitle')
Dim Const $sSettingBtnInSaveAsDlg 						  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SettingBtnInSaveAsDlg'))
Dim Const $sSaveAnnoToPMCtrlInfo 						  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SaveAnnoToPM'))
Dim Const $sSaveAnnoToAllAPCtrlInfo 					  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SaveAnnoToAllAP'))
Dim Const $sNotSaveAnnoCtrlInfo 						  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'NotSaveAnno'))
Dim Const $sOKBtnInSaveAsSettingDlgCtrlInfo 			  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'OKBtnInSaveAsSettingDlg'))
Dim Const $sSaveAsHotKey 								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SaveAsHotKey')
Dim Const $sTileButtonInToolBarCtrlInfo 				  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'TileButtonInToolBar'))
Dim Const $sSetFileUnchckContextMenuHotKey 				  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SetFileUnchckContextMenu')
Dim Const $sSetFileChckContextMenuHotKey 				  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SetFileChckContextMenu')
Dim Const $sSetFileUnchckEditMenuHotKey 				  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SetFileUnchckEditMenu')
Dim Const $sUnstackMenuHotKey 							  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'UnstackMenu')
Dim Const $sToolsMenuHotKey 							  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'ToolsMenu')
Dim Const $sUnstackContextMenuHotKey 					  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'UnstackContextMenu')
Dim Const $sStackMenuHotKey 							  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'StackMenu')
Dim Const $sStackContextMenuHotKey 						  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'StackContextMenu')
Dim Const $MoveToNextMenu 								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'MoveToNextMenu')
Dim Const $MoveToLastMenu 								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'MoveToLastMenu')
Dim Const $MoveToFirstMenu 								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'MoveToFirstMenu')
Dim Const $MoveToPrevMenu 								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'MoveToPrevMenu')
Dim Const $ArrangeStackContextMenu 						  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'ArrangeStackContextMenu')
Dim Const $MoveToNextContextMenu 						  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'MoveToNextContextMenu')
Dim Const $UnstackButtonInToolbar 						  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'UnstackButtonInToolbar'))
Dim Const $AllPagesMenu 								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'AllPagesMenu')
Dim Const $CurrentPagesMenu 							  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'CurrentPagesMenu')
Dim Const $SwitchViewToContextMenu 						  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SwitchViewToContextMenu')
Dim Const $OCRDialogTitle 								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'OCRDialogTitle')
Dim Const $OCRView 										  = ReadIniKeyValue($sPCodeIniPath, 'OCR', 'OCRResultView')
Dim Const $PerforOCRMenu	 							  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'PerforOCRMenu')
Dim Const $PerforOCRContextMenu							  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'PerforOCRContextMenu')
Dim Const $SwicthToTileViewButtonInToolbar				  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SwicthToTileViewButtonInToolbar'))
Dim Const $SortMenu									 	  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SortMenu')
Dim Const $ByAscending									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'ByAscendingMenu')
Dim Const $ByDescending									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'ByDescendingMenu')
Dim Const $ByType										  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'ByTypeMenu')
Dim Const $BySize										  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'BySizeMenu')
Dim Const $ByName										  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'ByNameMenu')
Dim Const $ByAuthor										  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'ByAuthorMenu')
Dim Const $ByDate										  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'ByDateMenu')
Dim Const $ByKeyword									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'ByKeywordMenu')
Dim Const $RenameContextMenu							  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'RenameContextMenu')
Dim Const $ZoomInButton									  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'ZoomInButton'))
Dim Const $NormalMenu									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'NormalMenu')
Dim Const $LargerMenu									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'LargerMenu')
Dim Const $LargeMenu									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'LargeMenu')
Dim Const $SmallMenu									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SmallMenu')
Dim Const $SmallerMenu									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SmallerMenu')
Dim Const $ZoomOutButton								  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'ZoomOutButton'))
Dim Const $DocumentPallet								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'DocumentPallet')
Dim Const $PreferenceDialogTitle						  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'PreferenceDialogTitle')
Dim Const $AlwaysOpenByThisWay							  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'AlwaysOpenByThisWay'))
Dim Const $CutContextMenu								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'CutContextMenu')
Dim Const $CopyContextMenu								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'CopyContextMenu')
Dim Const $PasteContextMenu								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'PasteContextMenu')
Dim Const $CutMenu										  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'CutMenu')
Dim Const $PasteMenu									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'PasteMenu')
Dim Const $CopyMenu										  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'CopyMenu')
Dim Const $Undo										 	  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'Undo')
Dim Const $Redo											  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'Redo')
Dim Const $NoButtonOnReplaceFileDlg						  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'NoButtonOnReplaceFileDlg'))
Dim Const $YesButtonOnReplaceFileDlg					  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'YesButtonOnReplaceFileDlg'))
Dim Const $YestoAllButtonOnReplaceFileDlg				  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'YestoAllButtonOnReplaceFileDlg')
Dim Const $RenameMenu									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'RenameMenu')
Dim Const $BatchRenamDialogTitle						  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'BatchRenamDialogTitle')
Dim Const $Prefix_BatchRename							  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'Prefix_BatchRename'))
Dim Const $StartName_BatchRename						  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'StartName_BatchRename'))
Dim Const $OK_BtnBatchRename							  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'OK_BtnBatchRename'))
Dim Const $BatchRenameContextMenu						  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'BatchRenameContextMenu')
Dim Const $BatchRenameMenu								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'BatchRenameMenu')
Dim Const $PrintFaxMenu									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'PrintFaxMenu')
Dim Const $PrintContextMenu								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'PrintContextMenu')
Dim Const $MergePDFMenu									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'MergePDFMenu')
Dim Const $SplitPDFMenu									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SplitPDFMenu')
Dim Const $DeleteContextMenu							  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'DeleteContextMenu')
Dim Const $DeleteMenu									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'DeleteMenu')
Dim Const $RefreshContextMenu							  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'RefreshContextMenu')
Dim Const $RefreshMenu									  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'RefreshMenu')
Dim Const $SelectAllContextMenu							  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'SelectAllContextMenu')
Dim Const $PropertiesMenu								  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'PropertiesMenu')
Dim Const $MoveFileMessageTitle							  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameThumbanil, 'MoveFileMessageTitle')
Dim Const $PageViewerViewer				          		  = ReadIniKeyValue($sPCodeIniPath, "Page view", 'PageViewerViewer')
Dim Const $MoveFileMessageTitle_ = ""



Func ChooseMyPagemanagerFolder($hPMHandle)
	Local $hTree = ControlGetHandle($hPMHandle, "", $sTreeViewCtrInfo)	
	If $hTree <> "" Then
		Local $hItemFound = _GUICtrlTreeView_FindItem($hTree, @UserName)
		If $hItemFound <> 0 Then
			_GUICtrlTreeView_Expand($hTree,$hItemFound,True)
			Sleep(500)
			;Local $hItemFound1 = _GUICtrlTreeView_FindItem($hTree, "My Documents")
				Local $hItemFound1 = _GUICtrlTreeView_FindItem($hTree, "Documents")
				If $hItemFound1 == 0 Then $hItemFound1 = _GUICtrlTreeView_FindItem($hTree, $sMyDocuments)
			If $hItemFound1 <> 0 Then
				_GUICtrlTreeView_Expand($hTree,$hItemFound1,True)
				Sleep(500)	
				Local $hItemFound2 = _GUICtrlTreeView_FindItem($hTree, "My PageManager")
				If $hItemFound2 <> 0 Then
				_GUICtrlTreeView_ClickItem($hTree, $hItemFound2)
				_GUICtrlTreeView_SelectItem($hTree, $hItemFound2)
				Sleep(300)
				Return 1
				EndIf
			EndIf
		EndIf
	EndIf
	Return @error
EndFunc


Func FileEXIFTab()
	Local $h = ControlGetHandle($CommonWindowCtrlInfro, "",12320)
	_GUICtrlTab_ClickTab($h, 2)
	Sleep(1000)
EndFunc


Func FileContenTab()
	Local $h = ControlGetHandle($CommonWindowCtrlInfro, "",12320)
	_GUICtrlTab_ClickTab($h, 1)
	Common_SleepTime(2)	
EndFunc

Func AddAudioMemo()
	; Add audio memo
	ControlClick($CommonWindowCtrlInfro,"",1025)   ; Add audio meno
	Common_SleepTime(2)	
	ControlSetText($CommonWindowCtrlInfro,"",1152,$sFEFolderPath & 'WAV.wav') 
	Common_SleepTime(1)	
	ControlClick($CommonWindowCtrlInfro,"",'Button2')  ; Open button.
	Common_SleepTime(2)
EndFunc	
Func AddKeyword($s)
	ControlClick($CommonWindowCtrlInfro, "", 1032)   
	WinWaitActive($CommonWindowCtrlInfro, "", 5)
	Common_SleepTime(1)
	ControlFocus($CommonWindowCtrlInfro, "", 1059)
	ControlSetText($CommonWindowCtrlInfro, "", 1059, $s)   ; Set the file name.
	Common_SleepTime(1)
	ControlClick($CommonWindowCtrlInfro, "", 1056)   ; Click add button.
	ControlClick($CommonWindowCtrlInfro, "", 1)   ; Click OK button.
	Common_SleepTime(1)
	ControlClick($CommonWindowCtrlInfro, "", 1)   ; Click OK button.
EndFunc



Func AddAuthor($Name)
	ControlClick($CommonWindowCtrlInfro, "", 1031)   
	WinWaitActive($CommonWindowCtrlInfro, "", 5)
	Common_SleepTime(1)
	ControlFocus($CommonWindowCtrlInfro, "", 1059)
	ControlSetText($CommonWindowCtrlInfro, "", 1059, $Name)   ; Set the file name.
	Common_SleepTime(1)
	ControlClick($CommonWindowCtrlInfro, "", 1056)   ; Click add button.
	ControlClick($CommonWindowCtrlInfro, "", 1)   ; Click OK button.
	Common_SleepTime(1)
	ControlClick($CommonWindowCtrlInfro, "", 1)   ; Click OK button.
	Common_SleepTime(2)
EndFunc

Func ClicKAddKeywordButton()
	ControlClick($CommonWindowCtrlInfro, '' , 1032)
	Common_SleepTime(2)
EndFunc

Func SelectAllFromContextMenu()
	For $i = 0 to 2
		Send($SelectAllContextMenu)
		Sleep(300)
	Next
	Send('{ENTER}')
	Common_SleepTime(2)		
EndFunc

Func ClicKAddAuthorButton()
	ControlClick($CommonWindowCtrlInfro, '' , 1031)
	Common_SleepTime(2)
EndFunc

Func DeleteFromEditMenu()
	OpenMenu("Edit")
	Send($DeleteMenu)	
	Common_SleepTime(1)	
	Send('{ENTER}')
	Common_SleepTime(2)	
EndFunc

Func MergePDF($sName)
	Common_SleepTime(2)	
	WinWaitActive ($CommonWindowCtrlInfro, '', 5)
	WinActivate($CommonWindowCtrlInfro)
	ControlSetText($CommonWindowCtrlInfro, '', 1152, $sName)    ;Set file name.
	Common_SleepTime(1)
	ControlClick($CommonWindowCtrlInfro, '', 'Button2')   ;OK button
	Common_SleepTime(4)
EndFunc

Func SetSplitPDFPrefixName($sName)
	WinWaitActive ($CommonWindowCtrlInfro, '', 5)
	WinActivate($CommonWindowCtrlInfro)	
	ControlSetText($CommonWindowCtrlInfro, '', 1105, $sName)    ;Set file name.
	Common_SleepTime(1)
EndFunc

Func SetSplitPDFStartNumber($sName)
	WinWaitActive ($CommonWindowCtrlInfro, '', 5)
	WinActivate($CommonWindowCtrlInfro)	
	ControlSetText($CommonWindowCtrlInfro, '', 1108, $sName)    ;Set file name.
	Common_SleepTime(1)
EndFunc

Func ClickOKOnSplitPDF()
	WinWaitActive ($CommonWindowCtrlInfro, '', 5)
	WinActivate($CommonWindowCtrlInfro)	
	ControlClick($CommonWindowCtrlInfro, '' , 'Button1')
	Common_SleepTime(3)	
EndFunc

Func SetSplitPDFDetPath($sName)
	WinWaitActive ($CommonWindowCtrlInfro, '', 5)
	WinActivate($CommonWindowCtrlInfro)	
	ControlClick($CommonWindowCtrlInfro, '' , 1103)
	
	
	ControlSetText($CommonWindowCtrlInfro, '', 1108, $sName)    ;Set file name.
	Common_SleepTime(1)
EndFunc



Func OpenSplitPDFFromMenu()
	Send("!" & $sToolsMenuHotKey)	
	Common_SleepTime(1)	
	For $i = 0 to 2 
		Send($SplitPDFMenu)	
		Sleep(300)
	Next
	Send("{ENTER}")
	Common_SleepTime(2)	
EndFunc

Func OpenMergePDFFromMenu()
	Send("!" & $sToolsMenuHotKey)	
	Common_SleepTime(1)	
	Send($MergePDFMenu)	
	Common_SleepTime(1)
	Send("{ENTER}")
	Common_SleepTime(4)	
EndFunc

Func SelectPrinterFromContextFileMenu($sPrinter)	
	Common_SleepTime(1)	
	Send($PrintContextMenu)
	Sleep(300)
	Send('{RIGHT}')
	Sleep(300)
	Switch $sPrinter
	Case 'Office Image Printer'
		For $i = 0 to 1
			Send("{DOWN}")
			Sleep(300)
		Next
	EndSwitch
	Send("{ENTER}")
	Common_SleepTime(4)
EndFunc


Func DeleteLastTimePrintFile($sName)
	If FileExists($sName) Then
		FileDelete($sName)
	EndIf
EndFunc

Func PrintFile($sName)
	Common_SleepTime(2)	
	WinWaitActive ($CommonWindowCtrlInfro, '', 5)
	WinActivate($CommonWindowCtrlInfro)
	Local $h = ControlGetHandle("[CLASS:#32770]", "FolderView", 23034)
	Local $sState = _GUICtrlButton_GetCheck($h)
	If $sState == 1 Then
		ControlClick("[CLASS:#32770]", "FolderView", 23034)   ;Uncheck when print finished preview  pewview file.
	EndIf
	ControlSetText("[CLASS:#32770]", "FolderView", 1148, $sName)    ;Set file name.
	Common_SleepTime(1)
	ControlClick($CommonWindowCtrlInfro, '', 'Button2')   ;OK button
	Common_SleepTime(4)
EndFunc

Func SelectPrinterFromFileMenu($sPrinter)
	Send("!" & $sFileMenuHotKey)	
	Common_SleepTime(1)	
	For $i = 0 to 1 
		Send($PrintFaxMenu)
	Next
	Common_SleepTime(1)
	Send('{RIGHT}')
	Common_SleepTime(1)
	Switch $sPrinter
	Case 'Office Image Printer'
	#cs	
		For $i = 0 to 4
			Send("{up}")
			Sleep(300)
		Next
	#ce
		For $i = 0 to 1
			Send("{DOWN}")
			Sleep(300)
		Next
	
	EndSwitch
	Send("{ENTER}")
	Common_SleepTime(4)
EndFunc


Func OpenBatchRenameFromContextMenu()
	Common_SleepTime(2)
	Send($BatchRenameContextMenu)
	Common_SleepTime(1)
EndFunc

Func OpenBatchRenameMenu()
	Common_SleepTime(2)
	Send("!" & $sToolsMenuHotKey)	
	Common_SleepTime(1)	
	Send($BatchRenameMenu)
	Common_SleepTime(1)
EndFunc

Func BatchRename($prefix, $statNumber)
	WinWaitActive($BatchRenamDialogTitle, "", 5)
	Sleep(1000)
	ControlSetText($BatchRenamDialogTitle, "", $Prefix_BatchRename, $prefix)
	Sleep(500)
	ControlSetText($BatchRenamDialogTitle, "", $StartName_BatchRename, $statNumber)
	Sleep(500)
	ControlClick($BatchRenamDialogTitle, "", $OK_BtnBatchRename)   ; OK button.
	Sleep(1500)
EndFunc


Func InputRenameString($s)
	Send($s)
	Common_SleepTime(1)
	Send('{ENTER}')
	Common_SleepTime(1)
EndFunc	
	
Func UndoFromEditMenu()
	OpenMenu("Edit")
	Send($Undo)	
	Common_SleepTime(2)	
EndFunc

Func RedoFromEditMenu()
	OpenMenu("Edit")
	Send($Redo)	
	Common_SleepTime(2)	
EndFunc

Func PasteFormEditMenu()
	OpenMenu("Edit")
	Send($PasteMenu)	
	Common_SleepTime(1)	
EndFunc

Func CutFormEditMenu()
	OpenMenu("Edit")
	Send($CutMenu)	
	Common_SleepTime(1)	
EndFunc

Func CopyFormEditMenu()
	OpenMenu("Edit")
	Send($CopyMenu)	
	Common_SleepTime(1)	
EndFunc

Func OpenMenu($sMenu)
	Switch $sMenu
	Case "Edit"
		Send("!" & $sEditMenuHotKey)	
		Common_SleepTime(2)	
	Case "Tools"
		Send("!" & $sToolsMenuHotKey)	
		Common_SleepTime(2)	
	Case "View"
		Send("!" & $sViewMenuHotKey)	
		Common_SleepTime(2)	
	Case "File"
		Send("!" & $sFileMenuHotKey)	
		Common_SleepTime(2)
	EndSwitch	
EndFunc

Func OpenWith($sOpenWay)
	WinWaitActive($PreferenceDialogTitle, '', 10)
	Common_SleepTime(2)
	WinActivate($PreferenceDialogTitle)
	Switch $sOpenWay
	Case "PageManager"
		
	Case "Associated AP"
		Send('{DOWN}')
	EndSwitch
	Send('{ENTER}')
	Common_SleepTime(10)	
EndFunc


Func CopySampleFile()
	Local $sPMVersion_ = $sPMVersion
	$sPMVersion_ = StringUpper($sPMVersion_)
	If $sPMVersion_ = 'FE' Then
		FileCopy($sFEFolderPath & '*.*', $sFunctionFolderPath, 1) 
	Else
		FileCopy($sSEFolderPath & '*.*', $sFunctionFolderPath, 1) 
	EndIf
EndFunc

Func ThumbnialSize($sSize)
	Switch $sSize
	Case "Larger"
	Case "Large"
		Send($LargeMenu)
		Common_SleepTime(1)		
	Case "Normal"	
		Send($NormalMenu)
		Common_SleepTime(1)		
	Case "Samll"	
		Send($SmallerMenu)
		Common_SleepTime(1)		
	Case "Samller"	
		Send($SmallerMenu)
		Common_SleepTime(1)		
		Send($SmallerMenu)
		Common_SleepTime(1)	
	EndSwitch
	Send('{ENTER}')
	Common_SleepTime(2)	
EndFunc


Func AddDisplayCoulmnInListView($sCoulmn)
	MouseClick('right',308,90)   ;Click fine name cloumn once.
	Common_SleepTime(1)
	Switch $sCoulmn
	Case 'Image Information'
		For $i = 0 to 3 
			Send("{DOWN}")
			Sleep(300)
		Next
		Send("{ENTER}")
		Common_SleepTime(1)
	Case 'Annotations'
		For $i = 0 to 7
			Send("{DOWN}")
			Sleep(300)
		Next
		Send("{ENTER}")
		Common_SleepTime(1)
	Case 'Keywords'
		For $i = 0 to 3 
			Send("{up}")
			Sleep(300)
		Next
		Send("{ENTER}")
		Common_SleepTime(1)
	Case 'Memory'
		For $i = 0 to 2 
			Send("{up}")
			Sleep(300)
		Next
		Send("{ENTER}")
		Common_SleepTime(1)
	Case 'Author'
		For $i = 0 to 1
			Send("{up}")
			Sleep(300)
		Next
		Send("{ENTER}")
		Common_SleepTime(1)
	EndSwitch
EndFunc

Func RenameByContextMenu($sName)
	Common_SleepTime(2)
	Send($RenameContextMenu)
	Common_SleepTime(1)
	Send($sName)
	Common_SleepTime(1)
	Send('{ENTER}')
	Common_SleepTime(1)
EndFunc

Func RenameByToolsMenu($sName)
	Send("!" & $sToolsMenuHotKey)	
	Common_SleepTime(1)	
	For $i = 0 to 1 
		Send($RenameMenu)
		Common_SleepTime(1)
	Next
	Send('{ENTER}')
	Common_SleepTime(1)
	Send($sName)
	Common_SleepTime(1)
	Send('{ENTER}')
	Common_SleepTime(1)	
EndFunc

Func Sort($SortWay)
	Send("!" & $sViewMenuHotKey)
	Common_SleepTime(1)
	Send('s')
	Common_SleepTime(1)
	Switch $SortWay
	Case "By Ascending"
		Send($ByAscending)
		Common_SleepTime(2)
	Case "By Descending"
		Send($ByDescending)
		Common_SleepTime(2)
	Case "By Type"
		Send($ByType)
		Common_SleepTime(2)		
	Case "By Size"
		Send($BySize)
		Common_SleepTime(2)		
	Case "By Name"
		Send($ByName)
		Common_SleepTime(2)	
	Case "By Author"
		Send($ByAuthor)
		Common_SleepTime(2)	
	Case "By Date"
		Send($ByDate)
		Common_SleepTime(2)		
	Case "By Keyword"
		Send($ByKeyword)
		Common_SleepTime(2)			
	EndSwitch
EndFunc	

Func SwitchToOCRFromContextMenu()
	OpenSwitchViewInContextMenu()
	Send($PerforOCRContextMenu)
	Common_SleepTime(3)	
EndFunc

Func PerformOCRFromToolsMenu()
	Send("!" & $sToolsMenuHotKey)	
	Common_SleepTime(1)	
	Send($PerforOCRMenu)
	Common_SleepTime(1)	
EndFunc

Func WaitOCRDlgClose($iSleepTime)
	Common_SleepTime($iSleepTime)	
	WinWaitActive($OCRDialogTitle, '', 10)
	WinWaitClose($OCRDialogTitle, '', 10)
	Common_SleepTime($iSleepTime)	
EndFunc

Func OpenSwitchViewInContextMenu()
	;Switch to OCR view in context menu.
	Send($SwitchViewToContextMenu)
	Common_SleepTime(1)
	Send("{right}")   
	Common_SleepTime(1)	
EndFunc

Func OpenToolsMenu()
	Send("!" & $sToolsMenuHotKey)	
	Common_SleepTime(1)
EndFunc

Func UnstackFormContextMenu()
	Send($sUnstackContextMenuHotKey)
	Common_SleepTime(1)
	Send($AllPagesMenu)
	Common_SleepTime(2)
EndFunc

Func SetCurrentSelectIsLastOfStackFiles()
	; set current select file is last of the stack files.
	MouseClick('left',319,101)  
	Common_SleepTime(1)
EndFunc

Func SetCurrentSelectIsMiddleOfStackFiles()
	; set current select file is middle of the stack files.
	MouseClick('left',319,101)  
	Common_SleepTime(1)
	MouseClick('left',319,101) 
	Common_SleepTime(1)
EndFunc

Func UnstackCurrentPageFromToolsMenu()
	Send("!" & $sToolsMenuHotKey)
	Sleep(500)	
	Send($sUnstackMenuHotKey)
	Sleep(500)	
	Send($CurrentPagesMenu)
	Sleep(1000)		
EndFunc

Func StackFileFroomContextMenu()
	Send($sStackContextMenuHotKey)
	Sleep(1000)	
EndFunc

Func StackFileFromMenu()
	Send("!" & $sToolsMenuHotKey)
	Sleep(500)	
	Send($sStackMenuHotKey)
	Sleep(500)	
	Send("{ENTER}")
	Sleep(1000)	
EndFunc

Func SetFileUnchekedFromEditMenu()
	Send("!" & $sEditMenuHotKey)
	Sleep(500)	
	Send($sSetFileUnchckEditMenuHotKey)
	Sleep(1000)
EndFunc

Func OpenSaveAsDialogFromContextMenu()
	Send($sSaveAsHotKey)
	Sleep(500)	
	Send($sSaveAsHotKey)
	Sleep(500)
	Send("{ENTER}")
	Sleep(2500)
EndFunc

Func OpenSaveAsDialogFromMenu()
	Send("!" & $sFileMenuHotKey)
	Sleep(500)	
	Send($sSaveAsHotKey)
	Sleep(2500)
EndFunc

Func SetSaveAsFormat($hSaveAsdialog,$Format)
	ControlClick("[CLASS:#32770]", "FolderView", $sSaveAsTypeCtrlInfo)
	Sleep(500)
	Switch $Format   
	Case "JPEG(*.JPG)"
		Send("j")
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "PaintBrush(*.PCX)"
		Send("p")
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "TIFF-uncompressed(*.TIF)"
		Send("t")
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "TIFF-packbits(*.TIF)"
		For $i = 0 to 1
			Send("t")
		Next
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "TIFF-G3 compression(*.TIF)"
		For $i = 0 to 2
			Send("t")
			Sleep(150)
		Next
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "TIFF-G4 compression(*.TIF)"
		For $i = 0 to 3
			Send("t")
			Sleep(150)
		Next
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "TIFF-multiple page(*.TIF)"
		For $i = 0 to 4
			Send("t")
			Sleep(150)
		Next
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "JPEG(*.JPG)"
		Send("j")
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "PICT(*.PCT)"
		Send("p")
		Send("p")
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "Targa(*.TGA)"
		For $i = 0 to 5
			Send("t")
			Sleep(150)
		Next
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "Targa-rle(*.TGA)"
		For $i = 0 to 6
			Send("t")
			Sleep(150)
		Next
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "PNG(*.PNG)"
		For $i = 0 to 2
			Send("p")
			Sleep(150)
		Next
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "Photoshop(*.PSD)"
		For $i = 0 to 3
			Send("p")
			Sleep(150)
		Next
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "GIF(*.GIF)"
		Send("g")
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "Text(*.TXT)"
		For $i = 0 to 7
			Send("t")
			Sleep(150)
		Next
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "Rich Text Format(*.RTF)"
		Send("r")
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	Case "HTML(*.HTM)"
		Send("h")
		Sleep(200)
		Send("{ENTER}")
		Sleep(500)
	EndSwitch
EndFunc

Func OpenThumbnailSizeMenu()
	; Choose "Thumbnail Size" item from "View" menu.
	Send("!" & $sViewMenuHotKey)
	Sleep(500)	
	Send($sThumbnailviewSizeHotKey)
	Sleep(500)
EndFunc

Func SwitchViewToMenu()
	; Choose "Thumbnail Size" item from "View" menu.
	Send("!" & $sViewMenuHotKey)
	Sleep(500)	
	Send($sSwitchToViewHotKey)
	Sleep(500)
	Send("{ENTER}")
	Sleep(1000)
EndFunc

Func UnselectDateColumnInListView_($PMTitle)
	; Unselect "Date Modified" and "Date create" in list view.
	Local $size = WinGetPos($PMTitle)   ;Get PM window postion and size.
	If $size <> 0 Then
		If MouseClick("right", $size[2] / 2.48, $size[3] / 11.35) Then
			Sleep(500)
			For $i = 0 to 4 
				Send("{DOWN}")
			Next
			Send("{ENTER}")
			Sleep(500)	
			If MouseClick("right", $size[2] / 2.48, $size[3] / 11.35) Then
				Sleep(500)	
				For $i = 0 to 5 
					Send("{DOWN}")
				Next
				Send("{ENTER}")
				Sleep(500)
			EndIf
		EndIf	
	EndIf
	Return @error
EndFunc

Func UnselectDateColumnInListView($PMTitle)
	; Unselect "Date Modified" and "Date create" in list view.
	Local $size = WinGetPos($PMTitle)   ;Get PM window postion and size.
	If $size <> 0 Then
		If MouseClick("right", $size[2] / 2.48, $size[3] / 11.35) Then
			Sleep(500)
			For $i = 0 to 4 
				Send("{DOWN}")
			Next
			Send("{ENTER}")
			Sleep(500)	
			If MouseClick("right", $size[2] / 2.48, $size[3] / 11.35) Then
				Sleep(500)	
				For $i = 0 to 5 
					Send("{DOWN}")
				Next
				Send("{ENTER}")
				Sleep(500)
			EndIf
			If MouseClick("right", $size[2] / 2.48, $size[3] / 11.35) Then
				Sleep(500)	
				For $i = 0 to 6 
					Send("{DOWN}")
				Next
				Send("{ENTER}")
				Sleep(500)
				Return 1
			EndIf
		EndIf	
	EndIf
	Return @error
EndFunc

Func InitializeStatusForThumbnail()
	;Delete all files in "C:\Thumbnail View\"
	
	Local $FileList = _FileListToArray ($sFunctionFolderPath,"*", 1)
	If Not @error Then
		If $FileList[0] >= 1 Then
			For $i = 1 to $FileList[0]
				FileDelete ($sFunctionFolderPath & $FileList[$i])
			Next
			Return 1
		EndIf
	EndIf
	If FileExists ( $sFunctionFolderPath ) Then
	Else
		MsgBox('','','Damn, thumbnail folder has just been deleted!!!!!')
	EndIf
	_ClipBoard_Empty()
EndFunc

Func SelectAllFilesFromMenu()
	MouseClick("left",572,354)   ;Clicl any area in thumbnail to get focus in thumbnail.
	Sleep(500)
	Send("!e")   ;Edit menu.
	Sleep(500)	
	Send('s')   ;Set all files as checked.
	Sleep(500)
	Send('s')   ;Select all files.
	Sleep(500)
	Send("{ENTER}")
	Sleep(1000)
EndFunc

Func SaveAnnotationOptionForSaveAs($sOption,$sSaveAsTitle)
	Local $sRe = ControlClick($sSaveAsTitle, "", $sSettingBtnInSaveAsDlg) 
	Sleep(1000)
	If Not @error Or $sRe = 0 Then
	Else
		Return @error
	EndIf
	Switch $sOption
	Case "Save to PM"
		Local $sRe = ControlClick($sSaveAnnotationSettingDlgTitle, "", $sSaveAnnoToPMCtrlInfo) 
		If Not @error Or $sRe = 0 Then
			Sleep(500)
		Else
			Return @error
		EndIf	
	Case "Save to All AP"
		Local $sRe = ControlClick($sSaveAnnotationSettingDlgTitle, "", $sSaveAnnoToAllAPCtrlInfo) 
		If Not @error Or $sRe = 0 Then
			Sleep(500)
		Else
			Return @error
		EndIf	
	Case "Not Save Annotation"
		Local $sRe = ControlClick($sSaveAnnotationSettingDlgTitle, "", $sNotSaveAnnoCtrlInfo) 
		If Not @error Or $sRe = 0 Then
			Sleep(500)
		Else
			Return @error
		EndIf		
	EndSwitch
	Sleep(500)
	Local $sRe = ControlClick($sSaveAnnotationSettingDlgTitle, "", 1)   ; Click "OK" button.
	Sleep(500)
	If Not @error Or $sRe = 0 Then
	Else
		Return @error
	EndIf	
EndFunc
;-------------------------------------------------------------------------------------------------
#cs
Func addAuthor($Name)
	ControlClick("File Properties", "", 1031)   
	WinWaitActive("Add/Remove Authors", "", 5)
	Common_SleepTime(1)
	ControlFocus("Add/Remove Authors", "", "Edit1")
	ControlSetText("Add/Remove Authors", "", "Edit1", $Name)   ; Set the file name.
	Common_SleepTime(1)
	ControlClick("Add/Remove Authors", "", 1056)   ; Click add button.
	ControlClick("Add/Remove Authors", "", 1)   ; Click OK button.
	Common_SleepTime(1)
	ControlClick("File Properties", "", 1)   ; Click OK button.
EndFunc

Func addKeyword($s)
	ControlClick("File Properties", "", 1032)   
	WinWaitActive("Add/Remove Keywords", "", 5)
	Common_SleepTime(1)
	ControlFocus("Add/Remove Keywords", "", "Edit1")
	ControlSetText("Add/Remove Keywords", "", "Edit1", $s)   ; Set the file name.
	Common_SleepTime(1)
	ControlClick("Add/Remove Keywords", "", 1056)   ; Click add button.
	ControlClick("Add/Remove Keywords", "", 1)   ; Click OK button.
	Common_SleepTime(1)
	ControlClick("File Properties", "", 1)   ; Click OK button.
EndFunc
Func checkThumbnialSize()
	; Current thumbnial size.
	Send("!v")
	Send(200)
	Send("T")
	Sleep(300)	
EndFunc

Func thumbnailSize($size)
	Send("!v")
	Send(200)
	Send("T")
	Sleep(300)	
	If $size = "Large" Then
		Send("l")
		Sleep(200)	
		Send("{ENTER}")
		Sleep(300)
	EndIf
	If $size = "Larger" Then	
		Send("{ENTER}")
		Sleep(300)
	EndIf	
	If $size = "Small" Then	
		Send("s")
		Sleep(200)
		Send("{ENTER}")
		Sleep(300)
	EndIf	
	If $size = "Smaller" Then	
		Send("s")
		Sleep(200)
		Send("s")
		Sleep(200)
		Send("{ENTER}")
		Sleep(300)
	EndIf	
EndFunc

Func batchRename($prefix, $statNumber)
	WinWaitActive("Batch Rename", "", 5)
	ControlSetText("Batch Rename", "", 1063, $prefix)
	Sleep(500)
	ControlSetText("Batch Rename", "", 1065, $statNumber)
	Sleep(500)
	ControlClick("Batch Rename", "", 1)   ; OK button.
	Sleep(1500)
EndFunc

Func printPDFwriter($Name)
	Send("!f")
	Sleep(500)
	Send("P")
	Sleep(500)
	Send("{ENTER}")
	Sleep(4500)
	If WinExists("Save As","FolderView") Then
		ControlSetText("Save As","FolderView",1152, $Name)
		Sleep(500)
		ControlClick("Save As","FolderView","Button2")   ; OK button.
		Sleep(2500)
		WinActivate("PageManager PDF Writer", "Printing to PDF format complete.")
		Send("{ENTER}")
	EndIf
EndFunc

Func printPDFwriterContextmenu($Name)
	Send("p")
	Sleep(500)
	Send("{ENTER}")
	Sleep(4500)
	If WinExists("Save As","FolderView") Then
		ControlSetText("Save As","FolderView",1152, $Name)
		Sleep(500)
		ControlClick("Save As","FolderView","Button2")   ; OK button.
		Sleep(2500)
		WinActivate("PageManager PDF Writer", "Printing to PDF format complete.")
		Send("{ENTER}")
	EndIf
EndFunc

Func mergePDF($Name)
	Send("!t")
	Sleep(500)
	Send("M")
	Sleep(500)
	Send("{ENTER}")
	Sleep(1500)
	If WinExists("Save All Files as","FolderView") Then
		ControlSetText("Save All Files as","FolderView",1152, $Name)
		Sleep(500)
		ControlClick("Save All Files as","FolderView","Button2")   ; OK button.
		Sleep(4500)
	EndIf
EndFunc

Func splitPDF($prefixName, $startNumber)
	Send("!t")
	Sleep(500)
	Send("s")
	Sleep(200)
	Send("s")
	Sleep(200)
	Send("s")
	Sleep(500)
	Send("{ENTER}")
	Sleep(1500)
	ControlFocus("Split PDF Settings", "", 1105)
	ControlSetText("Split PDF Settings", "", 1105,$prefixName)
	ControlFocus("Split PDF Settings", "", 1108)
	ControlSetText("Split PDF Settings", "", 1108,$startNumber)
	Sleep(200)
	ControlClick("Split PDF Settings", "", 1)
	Sleep(1500)
EndFunc

Func addAudioMemo($sAudioMemo)
	ControlClick("File Properties", "", 1025)   ; Click add button.
	Sleep(500)
	WinActive("Open", "FolderView")
	ControlFocus("Open", "FolderView",1152)
	ControlSetText("Open", "FolderView",1152,$sAudioMemo)
	Sleep(500)
	ControlClick("Open", "FolderView","Button2")
	Sleep(500)
EndFunc

Func fileContenTab()
	Local $h = ControlGetHandle("File Properties", "",12320)
	_GUICtrlTab_ClickTab($h, 1)
	Sleep(1000)
EndFunc

Func fileEXIFTab()
	Local $h = ControlGetHandle("File Properties", "",12320)
	_GUICtrlTab_ClickTab($h, 2)
	Sleep(1000)
EndFunc


Func TaskBar($Status)
	MouseMove(652, 772)
	Sleep(300)
	MouseClick("right", 696, 753)
	Sleep(300)
	Send("r")
	Sleep(800)
	Local $autoHide = _GUICtrlButton_GetCheck(ControlGetHandle("Taskbar and Start Menu Properties", "", 1102))
	Local $shown = _GUICtrlButton_GetCheck(ControlGetHandle("Taskbar and Start Menu Properties", "", 1101))
	If $Status = "show" Then
		If $autoHide = 1 Then
			ControlClick("Taskbar and Start Menu Properties", "", 1102)
		EndIf
		If $shown = 0 Then
			ControlClick("Taskbar and Start Menu Properties", "", 1101) 
		EndIf
		ControlClick("Taskbar and Start Menu Properties", "", 1)
		Sleep(300)
		MouseClick("left", 204, 159)
		Sleep(500)
	EndIf
	If $Status = "notShow" Then
		If $autoHide = 0 Then
			ControlClick("Taskbar and Start Menu Properties", "", 1102)
		EndIf
		If $shown = 1 Then
			ControlClick("Taskbar and Start Menu Properties", "", 1101) 
		EndIf
		ControlClick("Taskbar and Start Menu Properties", "", 1)
		Sleep(300)
		MouseClick("left", 204, 159)
		Sleep(500)
	EndIf	
EndFunc
#ce


